package Operation;

import Book.BookList;
import Book.Book;


import java.util.Scanner;

public class AddOperation implements IOperation{
    @Override
    public void work(BookList booklist) {
        int choic = 1;
        Scanner scanner = new Scanner(System.in);
        while(choic==1) {
            if (booklist.getUsedSize() < 10) {
                System.out.println("请输入名字》");
                String name = scanner.next();

                System.out.println("请输入作者》");
                String author = scanner.next();

                System.out.println("请输入价格》");
                int price = scanner.nextInt();

                System.out.println("请输入类型》");
                String type = scanner.next();

                Book book = new Book(name, author, price, type);
                booklist.setBook(book, booklist.getUsedSize());
                booklist.setUsedSize(booklist.getUsedSize()+1);
                System.out.println("添加成功");
            } else {
                System.out.println("书架满了，放不下了");
                break;
            }
            System.out.println("是否继续添加》  1》继续   0》停止  输入其他数字》停止");
            choic = scanner.nextInt();
        }
    }
}
